const express = require("express");
const router = express.Router();
const authMiddleware = require("../middleware/authMiddleware"); // 引入 Token 验证中间件
const MessageControllers = require("../controllers/messageControllers");

// 新增站内信
router.post("/add", authMiddleware, MessageControllers.addNewMsg);
// 根据 ID 删除站内信
router.delete("/del/:id", authMiddleware, MessageControllers.delMsgById);
// 获取全部站内信
router.get("/getAll", authMiddleware, MessageControllers.getAllMsgs);
// 根据发送人 ID 查找站内信
router.get(
  "/sender/:sendId/:isRead",
  // authMiddleware,
  MessageControllers.getMsgBySendId
);
// 根据接收人 ID 查找站内信
router.get(
  "/acter/:acceptId",
  authMiddleware,
  MessageControllers.getMsgByAcceptId
);
// 根据 ID 将消息标记为已读
router.patch("/read/:id", authMiddleware, MessageControllers.setMsgAsReadById);
// 获取来自系统的站内信
router.get("/sys", authMiddleware, MessageControllers.getSystemMsgs);
router.put("/msgs/:id",authMiddleware, MessageControllers.updateMsgById);
module.exports = router;
